The following is an article I originally published on Hackernoon. The Github repository can be found here. An interview I did regarding this can be found on the GunsNBitcoin podcast.